group { name: "e/modules/connman/main";
   images.image: "cloud-conn.png" COMP;

   images.image: "eth-top.png" COMP;
   images.image: "eth-base.png" COMP;

   images.image: "wifi-1.png" COMP;
   images.image: "wifi-2.png" COMP;
   images.image: "wifi-3.png" COMP;
   images.image: "wifi-4.png" COMP;
   images.image: "wifi-5.png" COMP;

   images.image: "bt-1.png" COMP;
   images.image: "bt-2.png" COMP;
   images.image: "bt-base.png" COMP;

   images.image: "cell-1.png" COMP;
   images.image: "cell-2.png" COMP;
   images.image: "cell-3.png" COMP;
   images.image: "cell-4.png" COMP;
   images.image: "cell-base.png" COMP;
   parts {
      part { name: "exclam_base"; mouse_events: 0;
         scale: 1;
         clip_to: "clip_exclam";
         description { state: "default" 0.0;
            min: 11 10;
            rel1.relative: (20/160) (50/160);
            rel2.relative: (135/160) (150/160);
            aspect: (115/105) (115/105); aspect_preference: BOTH;
            image.normal: "cloud-conn.png";
         }
      }
///////////////////////
      part { name: "eth-base"; mouse_events: 0;
         scale: 1;
         clip_to: "clip_eth";
         description { state: "default" 0.0;
            min: 6 13;
            aspect: (60/130) (60/130); aspect_preference: BOTH;
            rel1.relative: (50/160) (15/160);
            rel2.relative: (110/160) (145/160);
            image.normal: "eth-base.png";
            color_class: "/fg/disabled/gadgets/connman/eth/cable";
         }
         description { state: "connected" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/normal/gadgets/connman/eth/cable";
         }
         description { state: "online" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/selected/gadgets/connman/eth/cable";
         }
      }
      part { name: "eth"; mouse_events: 0;
         scale: 1;
         clip_to: "clip_eth";
         description { state: "default" 0.0;
            rel.to: "eth-base";
            image.normal: "eth-top.png";
            color_class: "/fg/disabled/gadgets/connman/eth/connector";
         }
         description { state: "connected" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/normal/gadgets/connman/eth/connector";
         }
         description { state: "online" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/normal/gadgets/connman/eth/connector";
         }
      }
///////////////////////
      part { name: "wifi-base"; mouse_events: 0;
         clip_to: "clip_wifi";
         description { state: "default" 0.0;
            image.normal: "wifi-1.png";
            color_class: "/fg/disabled/gadgets/connman/wifi/connected";
         }
         description { state: "connected" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/normal/gadgets/connman/wifi/connected";
         }
         description { state: "online" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/selected/gadgets/connman/wifi/connected";
         }
      }
      part { name: "wifi"; mouse_events: 0;
         clip_to: "clip_wifi";
         description { state: "default" 0.0;
            rel.to: "wifi-base";
            image.normal: "wifi-1.png";
            color_class: "/fg/normal/gadgets/connman/wifi/signal";
            color: 0 0 0 0; // no cc
         }
         description { state: "default" 0.25;
            inherit: "default" 0.0;
            image.normal: "wifi-2.png";
            color: 255 255 255 255; // no cc
         }
         description { state: "default" 0.5;
            inherit: "default" 0.0;
            image.normal: "wifi-3.png";
            color: 255 255 255 255; // no cc
         }
         description { state: "default" 0.75;
            inherit: "default" 0.0;
            image.normal: "wifi-4.png";
            color: 255 255 255 255; // no cc
         }
         description { state: "default" 1.0;
            inherit: "default" 0.0;
            image.normal: "wifi-5.png";
            color: 255 255 255 255; // no cc
         }
      }
///////////////////////
      part { name: "bt_base"; mouse_events: 0;
         clip_to: "clip_bt";
         description { state: "default" 0.0;
            image.normal: "bt-base.png";
            color_class: "/fg/normal/gadgets/connman/bt/base";
         }
      }
      part { name: "bt_1"; mouse_events: 0;
         clip_to: "clip_bt";
         description { state: "default" 0.0;
            rel.to: "bt_base";
            image.normal: "bt-1.png";
            color_class: "/fg/normal/gadgets/connman/bt/signal";
            visible: 0;
         }
         description { state: "partly" 0.0;
            inherit: "default" 0.0;
            color: 255 255 255 128; // no cc
            visible: 1;
         }
         description { state: "visible" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
      }
      part { name: "bt_2"; mouse_events: 0;
         clip_to: "clip_bt";
         description { state: "default" 0.0;
            rel.to: "bt_base";
            image.normal: "bt-2.png";
            color_class: "/fg/normal/gadgets/connman/bt/signal";
            visible: 0;
         }
         description { state: "partly" 0.0;
            inherit: "default" 0.0;
            color: 255 255 255 128; // no cc
            visible: 1;
         }
         description { state: "visible" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
      }
///////////////////////
      part { name: "cell_base"; mouse_events: 0;
         clip_to: "clip_cell";
         description { state: "default" 0.0;
            image.normal: "cell-base.png";
            color_class: "/fg/normal/gadgets/connman/cell/base";
         }
      }
      part { name: "cell_1"; mouse_events: 0;
         clip_to: "clip_cell";
         description { state: "default" 0.0;
            rel.to: "cell_base";
            image.normal: "cell-1.png";
            color_class: "/fg/normal/gadgets/connman/cell/signal";
            visible: 0;
         }
         description { state: "partly" 0.0;
            inherit: "default" 0.0;
            color: 255 255 255 128; // no cc
            visible: 1;
         }
         description { state: "visible" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
      }
      part { name: "cell_2"; mouse_events: 0;
         clip_to: "clip_cell";
         description { state: "default" 0.0;
            rel.to: "cell_base";
            image.normal: "cell-2.png";
            color_class: "/fg/normal/gadgets/connman/cell/signal";
            visible: 0;
         }
         description { state: "partly" 0.0;
            inherit: "default" 0.0;
            color: 255 255 255 128; // no cc
            visible: 1;
         }
         description { state: "visible" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
      }
      part { name: "cell_3"; mouse_events: 0;
         clip_to: "clip_cell";
         description { state: "default" 0.0;
            rel.to: "cell_base";
            image.normal: "cell-3.png";
            color_class: "/fg/normal/gadgets/connman/cell/signal";
            visible: 0;
         }
         description { state: "partly" 0.0;
            inherit: "default" 0.0;
            color: 255 255 255 128; // no cc
            visible: 1;
         }
         description { state: "visible" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
      }
      part { name: "cell_4"; mouse_events: 0;
         clip_to: "clip_cell";
         description { state: "default" 0.0;
            rel.to: "cell_base";
            image.normal: "cell-4.png";
            color_class: "/fg/normal/gadgets/connman/cell/signal";
            visible: 0;
         }
         description { state: "partly" 0.0;
            inherit: "default" 0.0;
            color: 255 255 255 128; // no cc
            visible: 1;
         }
         description { state: "visible" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
      }
///////////////////////
      part { name: "clip_exclam"; type: RECT;
         description { state: "default" 0.0;
            visible: 1;
         }
         description { state: "wifi" 0.0;
            visible: 0;
         }
         description { state: "eth" 0.0;
            visible: 0;
         }
         description { state: "bt" 0.0;
            visible: 0;
         }
         description { state: "cell" 0.0;
            visible: 0;
         }
      }
      part { name: "clip_wifi"; type: RECT;
         description { state: "default" 0.0;
            visible: 0;
         }
         description { state: "wifi" 0.0;
            visible: 1;
         }
         description { state: "eth" 0.0;
            visible: 0;
         }
         description { state: "bt" 0.0;
            visible: 0;
         }
         description { state: "cell" 0.0;
            visible: 0;
         }
      }
      part { name: "clip_eth"; type: RECT;
         description { state: "default" 0.0;
            visible: 0;
         }
         description { state: "wifi" 0.0;
            visible: 0;
         }
         description { state: "eth" 0.0;
            visible: 1;
         }
         description { state: "bt" 0.0;
            visible: 0;
         }
         description { state: "cell" 0.0;
            visible: 0;
         }
      }
      part { name: "clip_bt"; type: RECT;
         description { state: "default" 0.0;
            visible: 0;
         }
         description { state: "wifi" 0.0;
            visible: 0;
         }
         description { state: "eth" 0.0;
            visible: 0;
         }
         description { state: "bt" 0.0;
            visible: 1;
         }
         description { state: "cell" 0.0;
            visible: 0;
         }
      }
      part { name: "clip_cell"; type: RECT;
         description { state: "default" 0.0;
            visible: 0;
         }
         description { state: "wifi" 0.0;
            visible: 0;
         }
         description { state: "eth" 0.0;
            visible: 0;
         }
         description { state: "bt" 0.0;
            visible: 0;
         }
         description { state: "cell" 0.0;
            visible: 1;
         }
      }
      part { name: "event"; type: RECT;
         description { state: "default" 0.0;
            color: 0 0 0 0; // no cc
         }
      }
   }

#define SCRIPT_MESSAGE() \
script { \
public message(Msg_Type:type, id, ...) { \
if ((type == MSG_INT_SET) && (id == 1)) { \
new state = getarg(2), signl = getarg(3); \
set_state(PART:"wifi", "default", float(signl) / 100.0); \
if (signl <= 20) { \
set_state(PART:"bt_1", "default", 0.0); \
set_state(PART:"bt_2", "default", 0.0); \
} \
else if (signl <= 40) { \
set_state(PART:"bt_1", "partly", 0.0); \
set_state(PART:"bt_2", "default", 0.0); \
} \
else if (signl <= 60) { \
set_state(PART:"bt_1", "visible", 0.0); \
set_state(PART:"bt_2", "default", 0.0); \
} \
else if (signl <= 80) { \
set_state(PART:"bt_1", "visible", 0.0); \
set_state(PART:"bt_2", "partly", 0.0); \
} \
else { \
set_state(PART:"bt_1", "visible", 0.0); \
set_state(PART:"bt_2", "visible", 0.0); \
} \
if (signl <= 11) { \
set_state(PART:"cell_1", "default", 0.0); \
set_state(PART:"cell_2", "default", 0.0); \
set_state(PART:"cell_3", "default", 0.0); \
set_state(PART:"cell_4", "default", 0.0); \
} \
else if (signl <= 22) { \
set_state(PART:"cell_1", "partly", 0.0); \
set_state(PART:"cell_2", "default", 0.0); \
set_state(PART:"cell_3", "default", 0.0); \
set_state(PART:"cell_4", "default", 0.0); \
} \
else if (signl <= 33) { \
set_state(PART:"cell_1", "visible", 0.0); \
set_state(PART:"cell_2", "default", 0.0); \
set_state(PART:"cell_3", "default", 0.0); \
set_state(PART:"cell_4", "default", 0.0); \
} \
else if (signl <= 44) { \
set_state(PART:"cell_1", "visible", 0.0); \
set_state(PART:"cell_2", "partly", 0.0); \
set_state(PART:"cell_3", "default", 0.0); \
set_state(PART:"cell_4", "default", 0.0); \
} \
else if (signl <= 55) { \
set_state(PART:"cell_1", "visible", 0.0); \
set_state(PART:"cell_2", "visible", 0.0); \
set_state(PART:"cell_3", "default", 0.0); \
set_state(PART:"cell_4", "default", 0.0); \
} \
else if (signl <= 66) { \
set_state(PART:"cell_1", "visible", 0.0); \
set_state(PART:"cell_2", "visible", 0.0); \
set_state(PART:"cell_3", "partly", 0.0); \
set_state(PART:"cell_4", "default", 0.0); \
} \
else if (signl <= 77) { \
set_state(PART:"cell_1", "visible", 0.0); \
set_state(PART:"cell_2", "visible", 0.0); \
set_state(PART:"cell_3", "visible", 0.0); \
set_state(PART:"cell_4", "default", 0.0); \
} \
else if (signl <= 88) { \
set_state(PART:"cell_1", "visible", 0.0); \
set_state(PART:"cell_2", "visible", 0.0); \
set_state(PART:"cell_3", "visible", 0.0); \
set_state(PART:"cell_4", "partly", 0.0); \
} \
else { \
set_state(PART:"cell_1", "visible", 0.0); \
set_state(PART:"cell_2", "visible", 0.0); \
set_state(PART:"cell_3", "visible", 0.0); \
set_state(PART:"cell_4", "visible", 0.0); \
} \
if ((state == 2)) { \
   set_state(PART:"wifi-base", "default", 0.0); \
   set_state(PART:"eth-base", "default", 0.0); \
   set_state(PART:"eth", "default", 0.0); \
/*run_program(PROGRAM:"connecting");*/ \
return; } \
else if ((state == 3)) { return; } \
else if ((state == 4)) { \
   set_state(PART:"wifi-base", "connected", 0.0); \
   set_state(PART:"eth-base", "connected", 0.0); \
   set_state(PART:"eth", "connected", 0.0); \
} \
else if ((state == 5)) { \
   set_state(PART:"wifi-base", "online", 0.0); \
   set_state(PART:"eth-base", "online", 0.0); \
   set_state(PART:"eth", "online", 0.0); \
} \
else { \
   set_state(PART:"wifi-base", "default", 0.0); \
   set_state(PART:"eth-base", "default", 0.0); \
   set_state(PART:"eth", "default", 0.0); \
} } } }
   
   SCRIPT_MESSAGE()
   programs {
/*
      program { name: "connecting";
         action: STATE_SET "connected" 0.0;
         target: "led";
         in: 0.3 0.0;
         after:  "connecting2";
      }
      program { name: "connecting2";
         action: STATE_SET "default" 0.0;
         target: "led";
         in: 0.3 0.0;
         after:  "connecting";
      }
 */
//      program {
//         signal: "e,available"; source: "e";
//      }
//      program {
//         signal: "e,unavailable"; source: "e";
//      }
      program {
         signal: "e,changed,connected,no"; source: "e";
         action: STATE_SET "default" 0.0;
         target: "clip_exclam";
         target: "clip_wifi";
         target: "clip_eth";
         target: "clip_bt";
         target: "clip_cell";
      }
      program {
         signal: "e,changed,technology,wifi"; source: "e";
         action: STATE_SET "wifi" 0.0;
         target: "clip_exclam";
         target: "clip_wifi";
         target: "clip_eth";
         target: "clip_bt";
         target: "clip_cell";
      }
      program {
         signal: "e,changed,technology,ethernet"; source: "e";
         action: STATE_SET "eth" 0.0;
         target: "clip_exclam";
         target: "clip_wifi";
         target: "clip_eth";
         target: "clip_bt";
         target: "clip_cell";
      }
      program {
         signal: "e,changed,technology,bluetooth"; source: "e";
         action: STATE_SET "bt" 0.0;
         target: "clip_exclam";
         target: "clip_wifi";
         target: "clip_eth";
         target: "clip_bt";
         target: "clip_cell";
      }
      program {
         signal: "e,changed,technology,cellular"; source: "e";
         action: STATE_SET "cell" 0.0;
         target: "clip_exclam";
         target: "clip_wifi";
         target: "clip_eth";
         target: "clip_bt";
         target: "clip_cell";
      }
      program {
         signal: "e,changed,technology,other"; source: "e";
         action: STATE_SET "default" 0.0;
         target: "clip_exclam";
         target: "clip_wifi";
         target: "clip_eth";
         target: "clip_bt";
         target: "clip_cell";
      }
   }
}

group { name: "e/modules/connman/icon/wifi";
   inherit: "e/modules/connman/main";
   SCRIPT_MESSAGE()
   programs {
      program { signal: "load"; source: "";
         action: STATE_SET "wifi" 0.0;
         target: "clip_exclam";
         target: "clip_wifi";
         target: "clip_eth";
         target: "clip_bt";
         target: "clip_cell";
      }
   }
}

group { name: "e/modules/connman/icon/ethernet";
   inherit: "e/modules/connman/main";
   SCRIPT_MESSAGE()
   programs {
      program { signal: "load"; source: "";
         action: STATE_SET "eth" 0.0;
         target: "clip_exclam";
         target: "clip_wifi";
         target: "clip_eth";
         target: "clip_bt";
         target: "clip_cell";
      }
   }
}

group { name: "e/modules/connman/icon/bluetooth";
   inherit: "e/modules/connman/main";
   SCRIPT_MESSAGE()
   programs {
      program { signal: "load"; source: "";
         action: STATE_SET "bt" 0.0;
         target: "clip_exclam";
         target: "clip_wifi";
         target: "clip_eth";
         target: "clip_bt";
         target: "clip_cell";
      }
   }
}

group { name: "e/modules/connman/icon/cellular";
   inherit: "e/modules/connman/main";
   SCRIPT_MESSAGE()
   programs {
      program { signal: "load"; source: "";
         action: STATE_SET "cell" 0.0;
         target: "clip_exclam";
         target: "clip_wifi";
         target: "clip_eth";
         target: "clip_bt";
         target: "clip_cell";
      }
   }
}

group { name: "e/modules/connman/end";
   parts {
      part { name: "base"; mouse_events: 0;
         description { state: "default" 0.0;
            image.normal: "i-unlock";
            aspect: 1.0 1.0; aspect_preference: BOTH;
            color_class: "/fg/normal/gadgets/connman/security/none";
            visible: 0;
         }
         description { state: "none" 0.0;
            inherit: "default" 0.0;
            image.normal: "i-unlock";
            color_class: "/fg/normal/gadgets/connman/security/none";
            visible: 1;
         }
         description { state: "wep" 0.0;
            inherit: "default" 0.0;
            image.normal: "i-lock";
            color_class: "/fg/normal/gadgets/connman/security/secure/low";
            visible: 1;
         }
         description { state: "psk" 0.0;
            inherit: "default" 0.0;
            image.normal: "i-lock-double";
            color_class: "/fg/normal/gadgets/connman/security/secure/hi";
            visible: 1;
         }
      }
   }
   programs {
      program { signal: "e,security,off"; source: "e";
         action: STATE_SET "default" 0.0;
         target: "base";
      }
      program { signal: "e,security,none"; source: "e";
         action: STATE_SET "none" 0.0;
         target: "base";
      }
      program { signal: "e,security,wep"; source: "e";
         action: STATE_SET "wep" 0.0;
         target: "base";
      }
      program { signal: "e,security,psk"; source: "e";
         action: STATE_SET "psk" 0.0;
         target: "base";
      }
      program { signal: "e,security,ieee8021x"; source: "e";
         action: STATE_SET "psk" 0.0;
         target: "base";
      }
      program { signal: "e,security,wps"; source: "e";
         action: STATE_SET "wep" 0.0;
         target: "base";
      }
   }
}
